home *** CD-ROM | disk | FTP | other *** search
- <!--- This example shows the use of preserveSingleQuotes --->
- <HTML>
-
- <HEAD>
- <TITLE>
- PreserveSingleQuotes Example
- </TITLE>
- </HEAD>
-
- <BASEFONT FACE="Arial, Helvetica" SIZE=2>
- <BODY bgcolor="#FFFFD5">
-
- <H3>PreserveSingleQuotes Example</H3>
-
- <P>This is a useful function for creating lists of
- information to return from a query. In the following
- example, we pick the list of Centers in Suisun, San Francisco,
- and San Diego, using the SQL grammar IN to modify a WHERE
- clause rather than looping through the result set after
- the query is run.
-
- <CFSET List = "'Suisun', 'San Francisco', 'San Diego'">
-
- <CFQUERY NAME="GetCenters" DATASOURCE="cfsnippets">
- SELECT Name, Address1, Address2, City, Phone
- FROM Centers
- WHERE City IN (#PreserveSingleQuotes(List)#)
- </CFQUERY>
-
- <P>We found <CFOUTPUT>#GetCenters.RecordCount#</CFOUTPUT> records.
- <CFOUTPUT query="GetCenters">
- <P>#Name#<BR>
- #Address1#<BR>
- <CFIF Address2 is not "">#Address2#</CFIF>
- #City#<BR>
- #Phone#<BR>
- </CFOUTPUT>
- </BODY>
-
- </HTML>
-